fixed cargo bench --no-run
authordebris <marek.kotewicz@gmail.com>
Tue, 2 Feb 2016 10:30:28 +0000 (11:30 +0100)
committerdebris <marek.kotewicz@gmail.com>
Tue, 2 Feb 2016 10:30:28 +0000 (11:30 +0100)
src/cargo/ops/cargo_test.rs
tests/test_cargo_bench.rs

index d07b4bbae3a24df265f57ff344560ee3a82834b7..55a9ec5f08fa97997b6e975ac3a56af1b5fcabc8 100644 (file)
@@ -50,6 +50,10 @@ pub fn run_benches(manifest_path: &Path,
     let mut args = args.to_vec();
     args.push("--bench".to_string());
     let compilation = try!(compile_tests(manifest_path, options));
+
+    if options.no_run {
+        return Ok(None)
+    }
     let errors = try!(run_unit_tests(options, &args, &compilation));
     match errors.len() {
         0 => Ok(None),
index fe815d657485be3b793baad363799553eb90708e..737618629ef8873cb159d1c702cca39f807924eb 100644 (file)
@@ -922,6 +922,35 @@ test result: ok. 1 passed; 0 failed; 0 ignored; 0 measured
 ", compiling = COMPILING, running = RUNNING)));
 });
 
+test!(test_bench_no_run {
+    if !::is_nightly() { return }
+
+    let p = project("foo")
+        .file("Cargo.toml", r#"
+            [project]
+            name = "foo"
+            authors = []
+            version = "0.1.0"
+        "#)
+        .file("src/lib.rs", "")
+        .file("benches/bbaz.rs", r#"
+            #![feature(test)] 
+
+            extern crate test;
+
+            use test::Bencher;
+
+            #[bench]
+            fn bench_baz(_: &mut Bencher) {}
+        "#);
+
+    assert_that(p.cargo_process("bench").arg("--no-run"),
+                execs().with_status(0)
+                       .with_stdout(&format!("\
+{compiling} foo v0.1.0 ([..])
+", compiling = COMPILING)));
+});
+
 test!(test_bench_multiple_packages {
     if !::is_nightly() { return }